package com.example.demo.消费者;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
public class 消费者 {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @GetMapping("sendmsg")
    public String send( String msg){
        rabbitTemplate.convertAndSend("延时交换机",
                "延时队列routingkey",msg);
        return "OK";
    }

    @GetMapping("senddelay")
    public String sendDalay( String msg){
        rabbitTemplate.convertAndSend("延时交换机",
                "延时队列routingkey",msg);
        System.out.println("发送延时消息："+new Date());
        return "OK";
    }
}
